from pwn import *
from hashlib import sha256
import random
import string

def sha256_def(x,sha256_hash):
    a = string.ascii_letters + string.digits
    for i1 in a:
        for i2 in a:
            for i3 in a:
                for i4 in a:
                    c=i1+i2+i3+i4+x
                    c=c.encode()
                    if sha256(c).hexdigest() == sha256_hash:
                        return i1+i2+i3+i4


#nc 120.78.131.38 10001
sh = remote("120.78.131.38",10001)
context.log_level ='debug'
# sh.recvuntil(b"+ ")
#截取后半断的字符串
str_x=sh.recvuntil(b")")[:-1].decode()
# print(str_x)
sh.recvuntil(b":")
sha256_hash1=sh.recvuntil(b"\n").strip().decode()
# print(sha256_hash1)
data=sha256_def(str_x,sha256_hash1)
        sh.sendline(data.encode())
        for i in range(10,17):
            a1=str(i)
            sh.sendline(a1.encode())
            a=sh.recvline()
